<?php
namespace app\mall\controller;

use app\data\controller\api\Auth;
use app\mall\logic\couponLogic;

class Coupon extends Auth{

    //领券中心
    public function receivable_coupon(){
        $logic = new couponLogic();
        $data = $logic->receivable_coupon();
        $this->success('领券中心',$data);
    }

    //领取优惠券
    public function receive_coupon(){
        $id = request()->param('id',0);
        $logic = new couponLogic();
        $res = $logic->receive_coupon($this->uuid,$id);
        if ($res['code'] == 200) $this->success($res['msg']);
        $this->error($res['msg'],'',$res['code']);
    }

    //我的优惠券列表
    public function coupon_list(){
        $type = request()->param('type',0);
        $logic = new couponLogic();
        $data = $logic->coupon_list($this->uuid,$type);
        $this->success('我的优惠券列表',$data);
    }

    //付款时可使用的优惠券
    public function available_coupon(){
        $money = request()->param('money',0);
        $logic = new couponLogic();
        $data = $logic->available_coupon($this->uuid,$money);
        $this->success('付款时可使用的优惠券',$data);
    }

}